/**
 
 @Name : layui.popupTable 弹出选择表格
 @Author：fs
 
 */

layui.define(function(exports){
    "use strict";
    var $ = layui.$
    ,layer = layui.layer
    ,popupTable= function(options){
        return new Class(options);;
    }
    //构造器
    ,Class = function(options){
        var that = this;
        //生成Id
        that._id=Math.random().toString(36).substr(2);
        that.config = $.extend({}, that.config, options);
    };
  
    //默认配置
    Class.prototype.config = {
        single: true //是否单选
        ,where:false //查询条件
        ,tree:{
           url:''
           ,idField:'id'
           ,textField:'name'
           ,pidField:'pid' 
        }  //左边树配置
        ,callback: false //选择回掉
        ,table:false
    };
    //禁止选择的数据存储位置
    Class.prototype.disableIds=[];

    //清理数据
    Class.prototype.clear = function(){
        this.disableIds=[];
    };
    //设置禁用的数据
    Class.prototype.set = function(ids){
        this.disableIds=ids;
    };
    //移除对id的禁用
    Class.prototype.remove = function(id){
        for (var i = 0; i < this.disableIds.length; i++) {
            if (this.disableIds[i] == id){
                this.disableIds.splice(i, 1);
            }
        }
    };

    Class.prototype.setConfig=function(id){
        this.config = $.extend({}, this.config, options);
    };
    //打开弹出层
    Class.prototype.open = function(){
        if(this.config.tree){
            
        }
    };
    exports('popupTable', popupTable);
  });